From 54bf42c3e5f6603031f55f5e2187adb3c4f5c5da Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 8 Oct 2021 09:10:59 -0400 Subject: [PATCH] utils: Fix unreachable `NULL` deref by adding assertion Again this one is just in theory, but let's add an assertion. --- src/libotutil/ot-gio-utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libotutil/ot-gio-utils.c b/src/libotutil/ot-gio-utils.c index f09ee8af..9ee6f7d5 100644 --- a/src/libotutil/ot-gio-utils.c +++ b/src/libotutil/ot-gio-utils.c @@ -82,10 +82,13 @@ ot_gfile_ensure_unlinked (GFile *path, GCancellable *cancellable, GError **error) { - if (unlink (gs_file_get_path_cached (path)) != 0) + g_assert (path); + const char *pathc = gs_file_get_path_cached (path); + g_assert (pathc); + if (unlink (pathc) != 0) { if (errno != ENOENT) - return glnx_throw_errno_prefix (error, "unlink(%s)", gs_file_get_path_cached (path)); + return glnx_throw_errno_prefix (error, "unlink(%s)", pathc); } return TRUE; } -- 2.30.2